<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/24
 * Time: 12:16
 */
namespace app\index\controller;

use app\common\lib\Util;

class Chat
{
    public function index()
    {
        //登录，自行完善
        $game_id = intval($_POST['game_id']);
        if(empty($game_id)){
            return Util::show(config('code.error'), 'game id error');
        }
        $content = isset($_POST['content']) ? trim($_POST['content']) : "";
        if(empty($content)){
            return Util::show(config('code.error'), 'content is error');
        }
        $data = [
            'user' => '用户'  . rand(0, 2000),
            'content' => $content
        ];
        $task_data = [
            'method' => 'pushChat',
            'data' => $data
        ];
        $_POST['http_server']->task($task_data);

        return Util::show(config('code.success'), 'send success', $data);
    }
}